<?php
if(!$_GET['cgp'] || $_GET['cgp']!='361672a79bf8f6d9a8c81f61425e19ea') {
    exit('Access Denied');
}
include '/var/www/html/new/conf/le.je';
$le  = new go_sql();
$le->connect();
$where = '';
if (!empty($_GET['tbname'])) {
    $tbname = trim($_GET['tbname']);
    $where .= " AND tbname='{$tbname}'";
}
if (!empty($_GET['col_id'])) {
    $where .= " AND col_id=" . intval($_GET['col_id']);
}
if (!empty($_GET['if_sync'])) {
    $where .= " AND col_sync=" . intval($_GET['if_sync']);
}
if (!empty($_GET['origin'])) {
    $where .= " AND origin=" . intval($_GET['origin']);
}
//if (!empty($_GET['display_num']) || !empty($_GET['jump_page'])) {
//    $num =  abs($_GET['display_num']);
//    $page =  abs($_GET['jump_page']);
//    $offset = $num*$page;
//    $where .= " limit  $offset,$num";
//}
$sql = "SELECT * FROM sync_data WHERE 1=1 $where";
$le->query($sql);
$lists = array();
while($row = $le->fetch_assoc() ) {
    $lists[] = $row;
}

?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Show Me The Sync Data Log</title>
    <style>
        table{width:100%; border-spacing: 0; }
        td,th{border:1px solid #000;}
    </style>
</head>
<body>
<link type="text/css" rel="stylesheet" href="Calendar_personcustom.css" />
<form id="ourFrm" action="" method="get">
    <input name="cgp"  type="hidden" value="361672a79bf8f6d9a8c81f61425e19ea"/>
    <input name="action" type="hidden" value="sync_land"/>
    <p>tbname:
<!--        <input type="text" name="tbname" value="--><?//=$_GET['tbname']?><!--"/>-->
        <select name="tbname">
            <option value="">--select--</option>
            <option value="uu_land" <?=$_GET['tbname']=='uu_land'? 'selected':''?>>uu_land</option>
            <option value="uu_jq_ticket" <?=$_GET['tbname']=='uu_jq_ticket'? 'selected':''?>>uu_jq_ticket</option>
            <option value="uu_land_f" <?=$_GET['tbname']=='uu_land_f'? 'selected':''?>>uu_land_f</option>
            <option value="uu_products" <?=$_GET['tbname']=='uu_products'? 'selected':''?>>uu_products</option>
            <option value="uu_product_price" <?=$_GET['tbname']=='uu_product_price'? 'selected':''?>>uu_product_price</option>
        </select>
    </p>
    <p>Origin:<select name="origin" id="">
            <option value="1" <?=$_GET['origin']=='1'? 'selected':''?>>12301.cc</option>
            <option value="2" <?=$_GET['origin']=='2'? 'selected':''?>>16u.cc</option>
        </select></p>
    <p>col_id: <input type="number" name="col_id" value="<?=$_GET['col_id']?>"/> </p>
    <p>if_sync: <input type="number" name="if_sync" value="<?=$_GET['if_sync']?>"/> </p>
    <p>display_num: <input type="number" name="display_num" value="<?=$_GET['display_num']?>"/> </p>
    <p>jump_page: <input type="number" name="jump_page" value="<?=$_GET['jump_page']?>"/> </p>
    <input type="text" name="begintime" id="traleldateInp" class="playbeginDate" value="<?=$begintime?>"/>
    <p><button type="submit" id="BtnSubmit">Let's Search!</button></p>
</form>
<table>
    <thead>
    <tr>
        <th>ID</th>
        <th>LOG TIME</th>
        <th>Table Name</th>
        <th>COL</th>
        <th>COL ID</th>
        <th>CHG OLD</th>
        <th>CHG NEW</th>
        <th>SYNC TIME</th>
        <th>IF SYNC</th>
        <th>ORIGIN</th>
    </tr>
    <tbody>
    <?php foreach($lists as $list):?>
    <tr>
        <td><?=$list['id']?></td>
        <td><?=$list['log_time']?></td>
        <td><?=$list['tbname']?></td>
        <td><?=$list['col']?></td>
        <td><?=$list['col_id']?></td>
        <td><?=$list['chg_old']?></td>
        <td><?=$list['chg_new']?></td>
        <td><?=$list['sync_time']?></td>
        <td><?=$list['if_sync']?></td>
        <td><?=$list['origin']?></td>
    </tr>
    <?php endforeach;?>
    </tbody>
    </thead></table>
<script src="http://cdn.staticfile.org/jquery/1.9.0/jquery.min.js"></script>
<script src="Calendar.js"></script>
<script>
var Calend = (function(){
	
	function init(){
		$("#traleldateInp").val(Calendar.getnowdate())
		$(".playbeginDate").on("click",function(e){
			var target = $(e.currentTarget);
			var val = target.val();
			val = val.substring(0,7);
			Calendar.show(val,target);
		})
		$("#livingMod").on("click",".listUl .listLi input.dateInp",function(e){
			var target = $(e.currentTarget);
			var val = target.val();
			val = val.substring(0,7);
			Calendar.show(val,target);
		})
	}
	
	return {
		init : init
	}
	
})();
</script>
</body>
</html>